//
//  BGCollectionViewCell.m
//  LittleCool
//
//  Created by 周博 on 17/3/13.
//  Copyright © 2017年 BogoZhou. All rights reserved.
//

#import "BGCollectionViewCell.h"

@interface BGCollectionViewCell ()
{
    
}
@property (nonatomic,strong) MainListModel *mainListModel;

@end

@implementation BGCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
//    _imageViewImg.layer.masksToBounds = YES;
//    _imageViewImg.contentMode = UIViewContentModeScaleAspectFill;
//    _imageViewImg.layer.cornerRadius = kButtonCornerRadius * 2;
}

- (void)showDataWithModel:(MainListModel *)model{
    _mainListModel = model;
    [_imageViewImg sd_setImageWithURL:[NSURL URLWithString:model.icon]];
    _labelName.text = model.name;
    
    _buttonWenhao.imageEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
    
    _buttonWenhao.hidden = model.small_type.integerValue == 0 ? YES : NO;
}

- (IBAction)wenhaoButtonClick:(UIButton *)sender {
    
    NSString *string = [_mainListModel.small_prompt stringByReplacingOccurrencesOfString:@"&" withString:@"\n"];
        
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:string preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alert addAction:action];
    [[self viewController] presentViewController:alert animated:YES completion:nil];
    
}


- (UIViewController *)viewController {
    UIResponder *next = self.nextResponder;
    do {
        //判断响应者是否为视图控制器
        if ([next isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)next;
        }
        next = next.nextResponder;
    } while (next != nil);
    
    return nil;
}

@end
